import QrCode from 'qrcode-react'
import { apigetList } from '../api'
import React, { useEffect, useState } from 'react'
import { Table } from 'antd'


const Main = () => {

    const [list, setList] = useState([])

    useEffect(() => {
        getList()
    }, [])

    const getList = () => {
        apigetList().then(res => {
            setList(res.data)
        })
    }
    
    const columns = [
        {
            title: '用户名',
            dataIndex: 'username',
        },
        {
            title: '密码',
            dataIndex: 'password',
        },
        {
            title: '姓名',
            dataIndex: 'name',
        },
        {
            title: 'ID',
            dataIndex: 'id',
        },
        {
            title: '权限',
            dataIndex: 'auth',
        },
        {
            title: '操作',
            render: (data) => {
                return <QrCode value={`${JSON.stringify(data)}`} />
            }
        }
    ]


    return <div>
        <Table rowKey="id" dataSource={list} columns={columns} />
    </div>
}

export default Main